<?php

// On vérifie s'il y a une demande en jQuery
if (!empty($_GET['idVideoIcone']))
{
    require("../head.php") ;
    connect() ;
    $result = executerRequete("SELECT * FROM Video WHERE id=\"{$_GET['idVideoIcone']}\";", false) ;
    $row = mysql_fetch_assoc($result) ;
    mysql_close() ;
}

// Nombre de votes
connect() ;
$result = executerRequete("SELECT * FROM Note WHERE id_video=\"{$row['id']}\";", false) ;
$nbVotes = mysql_num_rows($result) ;
mysql_close() ;

// Calcul de la duree
$minutes = floor(intval($row['duree']) /60) ;
$secondes = $row['duree'] - 60*$minutes ;
$row['duree'] = $minutes . ":" . $secondes ;

$date = date('d/m/Y',convertirDate($row['date']));
echo <<<END
<div class="videoListe iconeVideo_{$row['id']}">
<div>
    <a href="index.php?page=video&amp;w={$row['id']}"><img src="apercus/apercu{$row['id']}.jpg" alt="Prévisualisation de la vidéo"></a>
</div>
<div>
    <a href="index.php?page=video&amp;w={$row['id']}">{$row['titre']}</a>
</div>
END;

// Note
if ($nbVotes > 0)
{
    echo "<div class=\"note\">" ;
    $noteIconesAJAX = $row["note_moyenne"] ;
    if (!empty($_GET['idVideoIcone'])) require ("noteVideoIcones.php") ;
    else require ("ajax/noteVideoIcones.php") ;
    echo "</div>";
}

if (niveauOK(2))
{
    echo "<div><a class=\"edition\" href=\"index.php?page=updateVideo&id={$row['id']}\">Editer</a>".PHP_EOL ;
    echo " - <a class=\"edition\" href=\"index.php?page=updateVideo&supprimer={$row['id']}\">Supprimer</a></div>".PHP_EOL ;
}
echo <<<END
</div>

END;


?>
